import { message } from 'antd';
import { getMemberCardInfo,getConsumeRecord } from '../service';

const Model = {
  namespace: 'cubeVipCardDetail',
  state: {
    vipCard:{},
    consumeRecord:[]
  },
  effects: {
    *getMemberCardInfo({ payload }, { call,put }) {
      let result=yield call(getMemberCardInfo, payload);
      if(result.code===0){
        yield put({
          type: 'common',
          payload: {
            vipCard:result.data
          }
        });
        return result.data
      }else{
        message.error(result.message);
      }
    },
    *getConsumeRecord({ payload }, { call,put }) {
      let result=yield call(getConsumeRecord, payload);
      if(result.code===0){
        yield put({
          type: 'common',
          payload: {
            consumeRecord:result.data
          }
        });
        return result.data
      }else{
        message.error(result.message);
      }
    },
  },
  reducers: {
    common(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },
  },
};
export default Model;
